SETUID
Section: System Calls (2)
Index
Return to Main Contents
BSD mandoc
BSD 4.2
NAME
setuid
seteuid
setgid
setegid
- set user and group ID
SYNOPSIS
Fd #include <sys/types.h>
Fd #include <unistd.h>
Ft int
Fn setuid uid_t uid
Ft int
Fn seteuid uid_t euid
Ft int
Fn setgid gid_t gid
Ft int
Fn setegid gid_t egid
DESCRIPTION
The
Fn setuid
function
sets the real and effective
user IDs and the saved set-user-ID of the current process
to the specified value.
The
Fn setuid
function is permitted if the specified ID is equal to the real user ID
of the process, or if the effective user ID is that of the super user.
The
Fn setgid
function
sets the real and effective
group IDs and the saved set-group-ID of the current process
to the specified value.
The
Fn setgid
function is permitted if the specified ID is equal to the real group ID
of the process, or if the effective user ID is that of the super user.
The
Fn seteuid
function
(Fn setegid
)
sets the effective user ID (group ID) of the
current process.
The effective user ID may be set to the value
of the real user ID or the saved set-user-ID (see
intro(2)
and
execve(2));
in this way, the effective user ID of a set-user-ID executable
may be toggled by switching to the real user ID, then re-enabled
by reverting to the set-user-ID value.
Similarly, the effective group ID may be set to the value
of the real group ID or the saved set-user-ID.
RETURN VALUES
Upon success, these functions return 0;
otherwise -1 is returned.
If the user is not the super user, or the uid
specified is not the real, effective ID, or saved ID,
these functions return -1.
SEE ALSO
getuid(2),
getgid(2)
STANDARDS
The
Fn setuid
and
Fn setgid
functions are compliant with the
St -p1003.1-88
specification with
_POSIX_SAVED_IDS
not defined.
The
Fn seteuid
and
Fn setegid
functions are extensions based on the
POSIX
concept of
_POSIX_SAVED_IDS
and have been proposed for a future revision of the standard.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUES
-
- SEE ALSO
-
- STANDARDS
-
This document was created by
man2html,
using the manual pages.
Time: 19:41:53 GMT, December 25, 2022